package entities 
{
	/**
	 * ...
	 * @author morgan
	 */
	public class Raft extends ReflectionSprite
	{
		[Embed (source = "../../data/raft.png")] private var img_raft:Class;
		
		public var targetY:Number = 0;
		public var speed:Number = 40;
		public function Raft(x:int, y:int, scene:GameScene) 
		{
			y += 3;
			super(x, y, scene, img_raft);
			velocity.x = -speed;
			targetY = y;
			immovable = true;
		}
		
		override public function update():void 
		{
			super.update();
			if (scene.tilemap.getTile(x / 16, y / 16))
			{
				velocity.x = speed;
			}
			if (scene.tilemap.getTile(x / 16 + 4, y / 16))
			{
				velocity.x = -speed;
			}
			if (scene.player.y < y &&
				scene.player.x + scene.player.width > x &&
				scene.player.x < x + width &&
				scene.player.y + scene.player.height > y - 2 &&
				scene.player.velocity.y >= 0)
			{
				velocity.y = scene.player.velocity.y / 2;
			}
			acceleration.y = (targetY - y) * 100 + 30;
			velocity.y *= 0.95;
		}
		
	}

}